/*
 * Copyright (c) 2009, Servoy-stuff
 * 
 * This library is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Lesser General Public License as published by the Free
 * Software Foundation; either version 2.1 of the License, or (at your option)
 * any later version.
 * 
 * This library is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
 * details.
 * 
 * You should have received a copy of the GNU Lesser General Public License
 * along with this library; if not, write to the Free Software Foundation, Inc.,
 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
 * http://www.fsf.org/licensing/licenses/lgpl.txt
 */

package net.stuff.servoy.beans.calendar;

import java.beans.PropertyDescriptor;
import java.beans.SimpleBeanInfo;
import java.util.ArrayList;
import java.util.List;

import com.servoy.j2db.dataui.PropertyEditorClass;
import com.servoy.j2db.dataui.PropertyEditorHint;
import com.servoy.j2db.util.Debug;

/**
 * @version 1.2 - 2010-03-01 - Servoy 5+
 * 
 * @author Servoy-stuff
 * http://www.servoy-stuff.net/
 */
public class DateChooserBeanBeanInfo extends SimpleBeanInfo {

	/* (non-Javadoc)
	 * @see java.beans.SimpleBeanInfo#getPropertyDescriptors()
	 */
	@Override
	public PropertyDescriptor[] getPropertyDescriptors()
    {
        try
        {
        	List<PropertyDescriptor> liste = new ArrayList<PropertyDescriptor>();
        	//liste.add(new PropertyDescriptor("dataProviderID", DateChooserBean.class));
        	PropertyDescriptor pd = new PropertyDescriptor("dataProviderID", DateChooserBean.class);
			PropertyEditorHint dpHint = new PropertyEditorHint(PropertyEditorClass.dataprovider);
			pd.setValue(PropertyEditorHint.PROPERTY_EDITOR_HINT, dpHint);
			liste.add(pd);
        	liste.add(new PropertyDescriptor("background", DateChooserBean.class));
        	pd = new PropertyDescriptor("border", DateChooserBean.class);
        	pd.setDisplayName("borderType");
        	liste.add(pd);
        	liste.add(new PropertyDescriptor("format", DateChooserBean.class));
        	liste.add(new PropertyDescriptor("editable", DateChooserBean.class));
        	pd = new PropertyDescriptor("font", DateChooserBean.class);
        	pd.setDisplayName("fontType");
        	liste.add(pd);
        	liste.add(new PropertyDescriptor("foreground", DateChooserBean.class));
        	liste.add(new PropertyDescriptor("minimumSize", DateChooserBean.class));
        	liste.add(new PropertyDescriptor("preferredSize", DateChooserBean.class));
        	liste.add(new PropertyDescriptor("toolTipText", DateChooserBean.class));
        	liste.add(new PropertyDescriptor("titleText", DateChooserBean.class));
        	liste.add(new PropertyDescriptor("location", DateChooserBean.class));
        	liste.add(new PropertyDescriptor("name", DateChooserBean.class));
        	liste.add(new PropertyDescriptor("size", DateChooserBean.class));
        	liste.add(new PropertyDescriptor("opaque", DateChooserBean.class));
        	liste.add(new PropertyDescriptor("selectOnEnter", DateChooserBean.class));
        	liste.add(new PropertyDescriptor("errorColor", DateChooserBean.class));
        	liste.add(new PropertyDescriptor("validColor", DateChooserBean.class));
        	liste.add(new PropertyDescriptor("horizontalAlignment", DateChooserBean.class));
        	
        	liste.add(new PropertyDescriptor("onAction", DateChooserBean.class));
        	liste.add(new PropertyDescriptor("onDataChange", DateChooserBean.class));
        	liste.add(new PropertyDescriptor("onFocusGained", DateChooserBean.class));
        	liste.add(new PropertyDescriptor("onFocusLost", DateChooserBean.class));

        	final String[] events = new String[] {
					"onAction",
					"onDataChange",
					"onFocusGained",
					"onFocusLost"
			};
			for (final String event : events) {
				pd = new PropertyDescriptor(event, DateChooserBean.class);
				dpHint = new PropertyEditorHint(PropertyEditorClass.method);
				pd.setValue(PropertyEditorHint.PROPERTY_EDITOR_HINT, dpHint);
				liste.add(pd);
			}
        	PropertyDescriptor apropertydescriptor[] = liste.toArray(new PropertyDescriptor[0]);
            return apropertydescriptor;
            
        }
        catch(Exception e)
        {
            Debug.error((new StringBuilder()).append("ServoyDateChooserBeanInfo: unexpected exception: ").append(e).toString());
        }
        return null;
    }
	
	/* (non-Javadoc)
	 * @see java.beans.SimpleBeanInfo#getDefaultPropertyIndex()
	 */
	@Override
	public int getDefaultPropertyIndex() {
		return 0;
	}
	
}
